﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;


namespace Pibby.Core.Tests.Web
{
	[TestClass]
	public class UriBuilderTests
	{
		[TestMethod]
		public void UriBuilder_GoodUri_IsUnchanged()
		{
			Uri unchanged = Pibby.Core.Web.UriBuilder.Create ("http://www.google.co.uk/");

			Assert.AreEqual ("http://www.google.co.uk/", unchanged.AbsoluteUri);
		}

		[TestMethod]
		public void UriBuilder_IncompleteUri_IsChanged()
		{
			Uri changed = Pibby.Core.Web.UriBuilder.Create("www.google.co.uk");

			Assert.AreEqual("http://www.google.co.uk/", changed.AbsoluteUri);
		}

		[TestMethod]
		public void UriBuilder_IncompleteDomainUri_IsChanged()
		{
			Uri changed = Pibby.Core.Web.UriBuilder.Create("ThisIsNotAUrl");

			Assert.AreEqual("http://thisisnotaurl/", changed.AbsoluteUri);
		}

		[TestMethod]
		[ExpectedException (typeof (UriFormatException))]
		public void UriBuilder_InvalidUri_ThrowsException()
		{
			Pibby.Core.Web.UriBuilder.Create("http:ThisIsNotAUrl");
		}

	}
}
